var models = require('../models/user.js');
var lession = require('../models/lession.js').lession;
module.exports.autoroute = {
	get:{
		'/admin':function(req,res){
			res.render("login")
		},
		'/admin/logout':function(req,res){
			req.session.user = null
			res.redirect("/admin");
		}
	},
	post:{
		'/admin/login':function(req,res){
			if(req.body.username&&req.body.password){
			  if(req.body.username == "admin"&&req.body.password=="admin"){
			    req.session.user = {username:'admin',role:'admin'};
			    res.json({code:1});
			    return;
			  }
			}
			res.json({code:0});
		},
		"/file-upload":function(req,res,next){
			res.json({path:req.files.file.path});
		}
	}
};

